spline

The spline function initializes the internal table for the calculation of interpolated values using cubic spline method. Interpolated values are obtained from calls to the C-calculator math function interp(). The value of the first derivative at the first and last data points can be specified by optional arguments. If not specified, or if one of the optional arguments is an asterisk *, then a natural cubic spline is assumed in which case the interpolated curve is such that the second derivative at the extreme points (or one of them) is null. The asterisk is more likely to be used in cases where the user would like to specify the first derivative at the last point only. The independent vector must be such that its value increases monotonically.

spline indep-VECTOR dep-VECTOR y1 yn

     # Read vectors having a functional relation Y = F(X) from file "datafile"
     read datafile X:1 Y:2
     # Initialize the spline (as being natural)
     spline X Y
     # Save extreme values
     let from = X[1]; to = X[data]
     # Say there were data=10 points and you want 100
     set data 100
     # Rebuild X vector
     # First build X ranging [0, 1]
     let x=0; X=x++; tmp=data-1; X/=tmp
     # Then from 'from' to 'to': from + (to - from)*X
     let tmp=(to-from); X = from + X*tmp
     # Rebuild Y vector possibly containing original values as a subset
     let Y = interp(X)
     # Note that any value can be asked for
     let interp(2.34*pi)

math interp